from Selenium2Library.keywords.keywordgroup import KeywordGroup
from Selenium2Library.locators import ElementFinder
from _breeze_account_summary import _BreezeAccountSummaryKeywords
from _breeze_mail import _BreezeMailKeywords
from _breeze_payee_list import _BreezePayeeListKeywords
from _breeze_transaction_list import _BreezeTransactionListKeywords
from _breeze_transfer import _BreezeTransferKeywords

class _BreezeCommonKeywords(_BreezeAccountSummaryKeywords, _BreezeMailKeywords, _BreezePayeeListKeywords, _BreezeTransactionListKeywords, _BreezeTransferKeywords):
    """Library for Breeze Common Keywords purposes.
    
    This library is used in Breeze projects.
    """
    def __init__(self):
        """Does nothing. init only"""
        print '_BreezeCommonKeywords.__init__'
        
    def select_frame(self, locator):
        """Sets frame identified by `locator` as current frame.

        Key attributes for frames are `id` and `name.` See `introduction` for
        details about locating elements.
        """
        self._info("Selecting frame '%s'." % locator)
        element = self._element_find(locator, True, True, tag='frame')
        self._current_browser().switch_to_frame(element)
        
    def select_iframe(self, locator):
        """Sets frame identified by `locator` as current frame.

        Key attributes for frames are `id` and `name.` See `introduction` for
        details about locating elements.
        """
        self._info("Selecting frame '%s'." % locator)
        element = self._element_find(locator, True, True, tag='iframe')
        self._current_browser().switch_to_frame(element)
    
        
    def select_top_frame_ibanking(self):
        '''Used for ID iBanking to select to top frame
        '''
        self._current_browser().switch_to_default_content()
        self.select_frame("//frame[@id='CenterContent']")
        self.select_iframe("//iframe[@id='iframename']")
        self.select_frame("//frame[@id='loginFrame']")
        self.select_frame("//frame[@name='loginTopFrame']")

    def select_links_frame_ibanking(self):
        """Used for ID iBanking to select to links frame which is at right side.
        Navigation bar.
        """
        self._current_browser().switch_to_default_content()
        self.select_frame("//frame[@id='CenterContent']")
        self.select_iframe("//iframe[@id='iframename']")
        self.select_frame("//frame[@id='loginlinksFrame']")


